/*
 * Copyright 2019 成都深地领航能源科技有限公司. All rights reserved.
 * PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.sdlh.demo.springboot.service.impl;

import com.sdlh.demo.springboot.dao.RecordMapper;
import com.sdlh.demo.springboot.po.RecordPO;
import com.sdlh.demo.springboot.service.RecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.context.WebApplicationContext;

import java.util.concurrent.CompletableFuture;

/**
 * @author 成都深地领航能源科技有限公司
 */
@Slf4j
@Service
@Scope(scopeName = WebApplicationContext.SCOPE_APPLICATION, proxyMode = ScopedProxyMode.INTERFACES)
public class RecordServiceImpl implements RecordService {
    @Autowired
    private RecordMapper recordMapper;

    @Override
    @Async
    public CompletableFuture<RecordPO> findItemAsync(int item, int table) {
        RecordPO record = recordMapper.findItem(item, table);
        log.info("获取到查询结果异步返回给controller");
        return CompletableFuture.completedFuture(record);
    }

    @Override
    public RecordPO findItem(int item, int table) {
        return recordMapper.findItem(item, table);
    }
}
